package com.jxchexie.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.jxchexie.model.SignIn;
import com.jxchexie.signin.R;

import java.util.ArrayList;

/**
 * Created by zj
 */
public class DangerAdminAdapter extends RecyclerView.Adapter<DangerAdminAdapter.ListViewHolder> {


    private ArrayList<SignIn> mdatas;

    private Context mContext;

    public DangerAdminAdapter(ArrayList<SignIn> datas, Context context) {
        mdatas = datas;
        mContext = context;
    }

    @Override
    public ListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ListViewHolder holder = new ListViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_admin_danger, parent, false));
        return holder;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(ListViewHolder holder, int position) {
        holder.user.setText(mdatas.get(position).getUser_name());
        holder.content.setText(mdatas.get(position).getUploadMessage());
    }

    @Override
    public int getItemCount() {
        if(mdatas==null || mdatas.size()<=0){
            return 0;
        }
        return mdatas.size();
    }


    class ListViewHolder extends RecyclerView.ViewHolder {
        TextView user;
        TextView content;
        public ListViewHolder(View itemView) {
            super(itemView);
            user=(TextView) itemView.findViewById(R.id.danger_user);
            content=(TextView) itemView.findViewById(R.id.danger_content);
        }
    }

}
